package com.lds.employment.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.lds.employment.domain.dto.StudentAssistanceDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.lds.employment.domain.EmploymentStudentAssistance;
import com.lds.employment.service.IEmploymentStudentAssistanceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 学生帮扶Controller
 * 
 * @author ruoyi
 * @date 2024-01-05
 */
@RestController
@RequestMapping("/student_ssistance")
public class EmploymentStudentAssistanceController extends BaseController
{
    @Autowired
    private IEmploymentStudentAssistanceService employmentStudentAssistanceService;

    /**
     * 查询学生帮扶列表
     */
    @RequiresPermissions("employment:student_ssistance:list")
    @GetMapping("/list")
    public TableDataInfo list(EmploymentStudentAssistance employmentStudentAssistance)
    {
        startPage();
        List<EmploymentStudentAssistance> list = employmentStudentAssistanceService.selectEmploymentStudentAssistanceList(employmentStudentAssistance);
        list.forEach(System.out::println);
        return getDataTable(list);
    }

    /**
     * 导出学生帮扶列表
     */
    @RequiresPermissions("employment:student_ssistance:export")
    @Log(title = "学生帮扶", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmploymentStudentAssistance employmentStudentAssistance)
    {
        List<EmploymentStudentAssistance> list = employmentStudentAssistanceService.selectEmploymentStudentAssistanceList(employmentStudentAssistance);
        ExcelUtil<EmploymentStudentAssistance> util = new ExcelUtil<EmploymentStudentAssistance>(EmploymentStudentAssistance.class);
        util.exportExcel(response, list, "学生帮扶数据");
    }

    /**
     * 获取学生帮扶详细信息
     */
    @RequiresPermissions("employment:student_ssistance:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(employmentStudentAssistanceService.selectEmploymentStudentAssistanceById(id));
    }

    /**
     * 新增学生帮扶
     */
    @RequiresPermissions("employment:student_ssistance:add")
    @Log(title = "学生帮扶", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmploymentStudentAssistance employmentStudentAssistance)
    {
        return toAjax(employmentStudentAssistanceService.insertEmploymentStudentAssistance(employmentStudentAssistance));
    }

    /**
     * 修改学生帮扶
     */
    @RequiresPermissions("employment:student_ssistance:edit")
    @Log(title = "学生帮扶", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmploymentStudentAssistance employmentStudentAssistance)
    {
        return toAjax(employmentStudentAssistanceService.updateEmploymentStudentAssistance(employmentStudentAssistance));
    }

    /**
     * 删除学生帮扶
     */
    @RequiresPermissions("employment:student_ssistance:remove")
    @Log(title = "学生帮扶", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(employmentStudentAssistanceService.deleteEmploymentStudentAssistanceByIds(ids));
    }
}
